<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- For Mobile Devices -->
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
        <meta name="generator" content="Doxygen 1.8.18"/>
        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
        <title>HElib: /HElib/include/helib/primeChain.h Source File</title>
        <!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
        <script type="text/javascript" src="dynsections.js"></script>
        <link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
        <link href='https://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css'>
		<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,100;1,700&family=Merriweather&family=Merriweather+Sans&family=Open+Sans&family=Poppins:ital@1&family=Roboto:ital,wght@0,400;1,300;1,900&display=swap" rel="stylesheet"> 
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
        <link href="jquery.smartmenus.bootstrap.css" rel="stylesheet">
        <script type="text/javascript" src="jquery.smartmenus.js"></script>
        <!-- SmartMenus jQuery Bootstrap Addon -->
        <script type="text/javascript" src="jquery.smartmenus.bootstrap.js"></script>
        <!-- SmartMenus jQuery plugin -->
    </head>
    <body style="font-family: 'Merriweather', serif;">
        <nav class="navbar navbar-default" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <a class="navbar-brand">HElib Implementing Homomorphic Encryption</a>
                </div>
            </div>
        </nav>
        <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
            <div class="content" id="content">
                <div class="container">
                    <div class="row">
                        <div class="col-sm-12 panel " style="padding-bottom: 15px;">
                            <div style="margin-bottom: 15px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_d0c4ae63660968bf6b1c77a1e8aecf95.html">helib</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">primeChain.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="prime_chain_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/* Copyright (C) 2012-2020 IBM Corp.</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * This program is Licensed under the Apache License, Version 2.0</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> * (the &quot;License&quot;); you may not use this file except in compliance</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * with the License. You may obtain a copy of the License at</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> *   http://www.apache.org/licenses/LICENSE-2.0</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> * Unless required by applicable law or agreed to in writing, software</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"> * See the License for the specific language governing permissions and</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> * limitations under the License. See accompanying LICENSE file.</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#ifndef HELIB_PRIMECHAIN_H</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#define HELIB_PRIMECHAIN_H</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160; </div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="_index_set_8h.html">helib/IndexSet.h</a>&gt;</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160; </div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacehelib.html">helib</a> {</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160; </div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="keyword">class </span>Cmodulus;</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160; </div>
<div class="line"><a name="l00026"></a><span class="lineno"><a class="line" href="classhelib_1_1_moduli_sizes.html">   26</a></span>&#160;<span class="keyword">class </span><a class="code" href="classhelib_1_1_moduli_sizes.html">ModuliSizes</a></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;{</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="classhelib_1_1_moduli_sizes.html#a498f82c06da7dc977f99d215a35481c7">   29</a></span>&#160;  <span class="keyword">typedef</span> std::pair&lt;double, IndexSet&gt; <a class="code" href="classhelib_1_1_moduli_sizes.html#a498f82c06da7dc977f99d215a35481c7">Entry</a>;</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;  <span class="comment">// each table entry is a pair&lt;double,IndexSet&gt;=(size, set-of-primes)</span></div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160; </div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classhelib_1_1_moduli_sizes.html#ad621f5c0fa4ce4bf037888eadb7db437">init</a>(<span class="keyword">const</span> std::vector&lt;Cmodulus&gt;&amp; chain,</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;            <span class="keyword">const</span> <a class="code" href="classhelib_1_1_index_set.html">IndexSet</a>&amp; ctxtPrimes,</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;            <span class="keyword">const</span> <a class="code" href="classhelib_1_1_index_set.html">IndexSet</a>&amp; smallPrimes);</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160; </div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;  <a class="code" href="classhelib_1_1_index_set.html">IndexSet</a> <a class="code" href="classhelib_1_1_moduli_sizes.html#a744ed05c1fccbc830cecb135eb1e7047">getSet4Size</a>(<span class="keywordtype">double</span> low,</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;                       <span class="keywordtype">double</span> high,</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;                       <span class="keyword">const</span> <a class="code" href="classhelib_1_1_index_set.html">IndexSet</a>&amp; fromSet,</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;                       <span class="keywordtype">bool</span> <a class="code" href="namespacehelib.html#a8dfd59b19280a7a98989bbc0dd6a8c2c">reverse</a>) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160; </div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;  <a class="code" href="classhelib_1_1_index_set.html">IndexSet</a> <a class="code" href="classhelib_1_1_moduli_sizes.html#a744ed05c1fccbc830cecb135eb1e7047">getSet4Size</a>(<span class="keywordtype">double</span> low,</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;                       <span class="keywordtype">double</span> high,</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;                       <span class="keyword">const</span> <a class="code" href="classhelib_1_1_index_set.html">IndexSet</a>&amp; from1,</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;                       <span class="keyword">const</span> <a class="code" href="classhelib_1_1_index_set.html">IndexSet</a>&amp; from2,</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;                       <span class="keywordtype">bool</span> <a class="code" href="namespacehelib.html#a8dfd59b19280a7a98989bbc0dd6a8c2c">reverse</a>) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160; </div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;  <span class="comment">// ASCII I/O</span></div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;  <span class="keyword">friend</span> std::istream&amp; <a class="code" href="classhelib_1_1_moduli_sizes.html#a24b050ab6dea3d2de34fc19b6de0c623">operator&gt;&gt;</a>(std::istream&amp; s, <a class="code" href="classhelib_1_1_moduli_sizes.html">ModuliSizes</a>&amp; szs);</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;  <span class="keyword">friend</span> std::ostream&amp; <a class="code" href="classhelib_1_1_moduli_sizes.html#a88a56d9aae0367fb953e7227d59c03ea">operator&lt;&lt;</a>(std::ostream&amp; s, <span class="keyword">const</span> <a class="code" href="classhelib_1_1_moduli_sizes.html">ModuliSizes</a>&amp; szs);</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;  <span class="comment">// Raw I/O</span></div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classhelib_1_1_moduli_sizes.html#a78e717d64823a8afe0b8c576cdbfd42d">read</a>(std::istream&amp; str);</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classhelib_1_1_moduli_sizes.html#a8ba402c9dcea5d4bf61bffe155ec031c">write</a>(std::ostream&amp; str) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160; </div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;  std::vector&lt;Entry&gt; sizes;</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;};</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160; </div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;std::ostream&amp; <a class="code" href="namespacehelib.html#addc58993c7093dd07d98335bab200e82">operator&lt;&lt;</a>(std::ostream&amp; s, <span class="keyword">const</span> <a class="code" href="classhelib_1_1_moduli_sizes.html#a498f82c06da7dc977f99d215a35481c7">ModuliSizes::Entry</a>&amp; e);</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;std::istream&amp; <a class="code" href="namespacehelib.html#a84b37f68c4bdc42558ad0360b00984fb">operator&gt;&gt;</a>(std::istream&amp; s, <a class="code" href="classhelib_1_1_moduli_sizes.html#a498f82c06da7dc977f99d215a35481c7">ModuliSizes::Entry</a>&amp; e);</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;<span class="keywordtype">void</span> <a class="code" href="namespacehelib.html#a39d92caff425c0086a87a667c88003d4">write</a>(std::ostream&amp; s, <span class="keyword">const</span> <a class="code" href="classhelib_1_1_moduli_sizes.html#a498f82c06da7dc977f99d215a35481c7">ModuliSizes::Entry</a>&amp; e);</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;<span class="keywordtype">void</span> <a class="code" href="namespacehelib.html#ac5197bb5b6cad37f9d4a4a7c7e7bf8d0">read</a>(std::istream&amp; s, <a class="code" href="classhelib_1_1_moduli_sizes.html#a498f82c06da7dc977f99d215a35481c7">ModuliSizes::Entry</a>&amp; e);</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160; </div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;} <span class="comment">// namespace helib</span></div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160; </div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;<span class="preprocessor">#endif // ifndef HELIB_PRIMECHAIN_H</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclasshelib_1_1_moduli_sizes_html_ad621f5c0fa4ce4bf037888eadb7db437"><div class="ttname"><a href="classhelib_1_1_moduli_sizes.html#ad621f5c0fa4ce4bf037888eadb7db437">helib::ModuliSizes::init</a></div><div class="ttdeci">void init(const std::vector&lt; Cmodulus &gt; &amp;chain, const IndexSet &amp;ctxtPrimes, const IndexSet &amp;smallPrimes)</div><div class="ttdoc">initialize helper table for a given chain</div><div class="ttdef"><b>Definition:</b> primeChain.cpp:56</div></div>
<div class="ttc" id="anamespacehelib_html_ac5197bb5b6cad37f9d4a4a7c7e7bf8d0"><div class="ttname"><a href="namespacehelib.html#ac5197bb5b6cad37f9d4a4a7c7e7bf8d0">helib::read</a></div><div class="ttdeci">void read(std::istream &amp;s, ModuliSizes::Entry &amp;e)</div><div class="ttdef"><b>Definition:</b> primeChain.cpp:49</div></div>
<div class="ttc" id="aclasshelib_1_1_index_set_html"><div class="ttname"><a href="classhelib_1_1_index_set.html">helib::IndexSet</a></div><div class="ttdoc">A dynamic set of non-negative integers.</div><div class="ttdef"><b>Definition:</b> IndexSet.h:31</div></div>
<div class="ttc" id="aclasshelib_1_1_moduli_sizes_html_a24b050ab6dea3d2de34fc19b6de0c623"><div class="ttname"><a href="classhelib_1_1_moduli_sizes.html#a24b050ab6dea3d2de34fc19b6de0c623">helib::ModuliSizes::operator&gt;&gt;</a></div><div class="ttdeci">friend std::istream &amp; operator&gt;&gt;(std::istream &amp;s, ModuliSizes &amp;szs)</div><div class="ttdef"><b>Definition:</b> primeChain.cpp:259</div></div>
<div class="ttc" id="aclasshelib_1_1_moduli_sizes_html_a744ed05c1fccbc830cecb135eb1e7047"><div class="ttname"><a href="classhelib_1_1_moduli_sizes.html#a744ed05c1fccbc830cecb135eb1e7047">helib::ModuliSizes::getSet4Size</a></div><div class="ttdeci">IndexSet getSet4Size(double low, double high, const IndexSet &amp;fromSet, bool reverse) const</div><div class="ttdef"><b>Definition:</b> primeChain.cpp:114</div></div>
<div class="ttc" id="a_index_set_8h_html"><div class="ttname"><a href="_index_set_8h.html">IndexSet.h</a></div><div class="ttdoc">A dynamic set of integers.</div></div>
<div class="ttc" id="anamespacehelib_html"><div class="ttname"><a href="namespacehelib.html">helib</a></div><div class="ttdef"><b>Definition:</b> apiAttributes.h:21</div></div>
<div class="ttc" id="aclasshelib_1_1_moduli_sizes_html_a88a56d9aae0367fb953e7227d59c03ea"><div class="ttname"><a href="classhelib_1_1_moduli_sizes.html#a88a56d9aae0367fb953e7227d59c03ea">helib::ModuliSizes::operator&lt;&lt;</a></div><div class="ttdeci">friend std::ostream &amp; operator&lt;&lt;(std::ostream &amp;s, const ModuliSizes &amp;szs)</div><div class="ttdef"><b>Definition:</b> primeChain.cpp:255</div></div>
<div class="ttc" id="aclasshelib_1_1_moduli_sizes_html_a498f82c06da7dc977f99d215a35481c7"><div class="ttname"><a href="classhelib_1_1_moduli_sizes.html#a498f82c06da7dc977f99d215a35481c7">helib::ModuliSizes::Entry</a></div><div class="ttdeci">std::pair&lt; double, IndexSet &gt; Entry</div><div class="ttdef"><b>Definition:</b> primeChain.h:29</div></div>
<div class="ttc" id="aclasshelib_1_1_moduli_sizes_html"><div class="ttname"><a href="classhelib_1_1_moduli_sizes.html">helib::ModuliSizes</a></div><div class="ttdoc">A helper class to map required modulo-sizes to primeSets.</div><div class="ttdef"><b>Definition:</b> primeChain.h:27</div></div>
<div class="ttc" id="anamespacehelib_html_addc58993c7093dd07d98335bab200e82"><div class="ttname"><a href="namespacehelib.html#addc58993c7093dd07d98335bab200e82">helib::operator&lt;&lt;</a></div><div class="ttdeci">std::ostream &amp; operator&lt;&lt;(std::ostream &amp;s, const SKHandle &amp;handle)</div><div class="ttdef"><b>Definition:</b> Ctxt.h:189</div></div>
<div class="ttc" id="aclasshelib_1_1_moduli_sizes_html_a8ba402c9dcea5d4bf61bffe155ec031c"><div class="ttname"><a href="classhelib_1_1_moduli_sizes.html#a8ba402c9dcea5d4bf61bffe155ec031c">helib::ModuliSizes::write</a></div><div class="ttdeci">void write(std::ostream &amp;str) const</div><div class="ttdef"><b>Definition:</b> primeChain.cpp:271</div></div>
<div class="ttc" id="anamespacehelib_html_a39d92caff425c0086a87a667c88003d4"><div class="ttname"><a href="namespacehelib.html#a39d92caff425c0086a87a667c88003d4">helib::write</a></div><div class="ttdeci">void write(std::ostream &amp;s, const ModuliSizes::Entry &amp;e)</div><div class="ttdef"><b>Definition:</b> primeChain.cpp:43</div></div>
<div class="ttc" id="anamespacehelib_html_a84b37f68c4bdc42558ad0360b00984fb"><div class="ttname"><a href="namespacehelib.html#a84b37f68c4bdc42558ad0360b00984fb">helib::operator&gt;&gt;</a></div><div class="ttdeci">std::istream &amp; operator&gt;&gt;(std::istream &amp;s, CtxtPart &amp;p)</div><div class="ttdef"><b>Definition:</b> Ctxt.cpp:1882</div></div>
<div class="ttc" id="aclasshelib_1_1_moduli_sizes_html_a78e717d64823a8afe0b8c576cdbfd42d"><div class="ttname"><a href="classhelib_1_1_moduli_sizes.html#a78e717d64823a8afe0b8c576cdbfd42d">helib::ModuliSizes::read</a></div><div class="ttdeci">void read(std::istream &amp;str)</div><div class="ttdef"><b>Definition:</b> primeChain.cpp:278</div></div>
<div class="ttc" id="anamespacehelib_html_a8dfd59b19280a7a98989bbc0dd6a8c2c"><div class="ttname"><a href="namespacehelib.html#a8dfd59b19280a7a98989bbc0dd6a8c2c">helib::reverse</a></div><div class="ttdeci">void reverse(NTL::Vec&lt; T &gt; &amp;v, long lo, long hi)</div><div class="ttdoc">Reverse a vector in place.</div><div class="ttdef"><b>Definition:</b> NumbTh.h:613</div></div>
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.18
</small></address>
</body>
        <script type="text/javascript" src="doxy-boot.js"></script>
</html>
